package kvoog.arkanoid.common;

import com.artemis.Component;

/**
 * This component provider always returns the same instance of the component. The instance
 * is passed to the provider at initialisation.
 * 
 * Ported from Ash entity component system framework for Action Script by Igor Knezevic. 
 * http://www.richardlord.net/blog/finite-state-machines-with-ash
 */
public class ComponentInstanceProvider implements IComponentProvider {

	private Component component;
	
	/**
	 * Constructor
	 *
	 * @param instance The instance to return whenever a component is requested.
	 */
	public ComponentInstanceProvider(Component component) {
		this.component = component;
	}

	/**
	 * Used to request a component from this provider
	 *
	 * @return The instance
	 */
	@Override
	public Component getComponent() {
		return component;
	}

	/**
	 * Used to compare this provider with others. Any provider that returns the same component
	 * instance will be regarded as equivalent.
	 *
	 * @return The instance
	 */
	@Override
	public int getId() {
		// TODO Not yet implemented !
		return 0;
	}

}
